<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of resize</title>
  <meta name="keywords" content="resize">
  <meta name="description" content="resize(g,n) --- change the number of vertices in g to n">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">matgraph</a> &gt; <a href="index.html">@graph</a> &gt; resize.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph/@graph&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>resize
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>resize(g,n) --- change the number of vertices in g to n</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function resize(g, n) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> resize(g,n) --- change the number of vertices in g to n
 note: if n is less than nv(g), vertices will be lost
 if the graph has an embedding, all new vertices are sited at the origin.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="hasxy.html" class="code" title="function yn = hasxy(g)">hasxy</a>	hasxy(g) --- determine if an embedding has been created for g</li><li><a href="is_labeled.html" class="code" title="function yn = is_labeled(g)">is_labeled</a>	is_labeled(g) --- determine if there are labels on vertices.</li><li><a href="isfull.html" class="code" title="function yn = isfull(g)">isfull</a>	isfull(g) --- check if g's adjacency matrix is full</li><li><a href="make_logical.html" class="code" title="function make_logical(g)">make_logical</a>	make_logical(g) --- ensure that the internal storage for g's matrix is a</li><li><a href="nv.html" class="code" title="function n = nv(g)">nv</a>	nv(g) --- number of vertices in g</li><li><a href="sparse.html" class="code" title="function sparse(g)">sparse</a>	sparse(g) --- convert internal storage for g to sparse</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="add.html" class="code" title="function add(g,i,j)">add</a>	add --- add edge(s) to the graph</li><li><a href="bfstree.html" class="code" title="function bfstree(t,g,v)">bfstree</a>	bfstree(t,g,v) --- create a breadth-first spanning tree of g</li><li><a href="cartesian.html" class="code" title="function cartesian(g,h1,h2)">cartesian</a>	cartesian(g,h1,h2) --- overwrite g with the product of h1 and h2</li><li><a href="cayley.html" class="code" title="function cayley(g,perms,verbose)">cayley</a>	cayley(g,perms) -- create a Cayley graph (undirected)</li><li><a href="circulant.html" class="code" title="function circulant(g,n,k)">circulant</a>	circulant(g,n,k) --- overwrite g with an n,k circulant graph</li><li><a href="cube.html" class="code" title="function cube(g,k)">cube</a>	cube(g,k) --- create a k-cube (default k = 3)</li><li><a href="dodecahedron.html" class="code" title="function dodecahedron(g)">dodecahedron</a>	dodecahedron(g) --- overwrite g with the dodecahedron graph</li><li><a href="fgraph.html" class="code" title="function fgraph(g,n,func)">fgraph</a>	fgraph(g,n,func) -- create a graph based on a function.</li><li><a href="grid.html" class="code" title="function grid(g,a,b)">grid</a>	grid(g,a,b) --- create an a-by-b grid graph</li><li><a href="icosahedron.html" class="code" title="function icosahedron(g)">icosahedron</a>	icosahedron(g) --- overwrite g with the icosahedron graph</li><li><a href="intersect.html" class="code" title="function intersect(g,h1,h2)">intersect</a>	intersect(g,h1,h2) --- g is set to the intersection of h1 and h2.</li><li><a href="interval_graph.html" class="code" title="function interval_graph(g,ilist)">interval_graph</a>	interval_graph(g,ilist) --- create an interval graph</li><li><a href="line_graph.html" class="code" title="function line_graph(g,h)">line_graph</a>	line_graph(g,h) --- set g to be the line graph of h</li><li><a href="load.html" class="code" title="function load(g,filename)">load</a>	load(g,filename) --- read a saved graph on disk</li><li><a href="octahedron.html" class="code" title="function octahedron(g)">octahedron</a>	octahedron(g) --- overwrite g with the octahedron graph, K(2,2,2)</li><li><a href="paley.html" class="code" title="function paley(g,n)">paley</a>	paley(g,n) --- create a Paley graph with n vertices</li><li><a href="path.html" class="code" title="function path(g,n)">path</a>	path(g,n) --- make g a path on n vertices</li><li><a href="petersen.html" class="code" title="function petersen(g)">petersen</a>	petersen(g) --- overwrite g with the Petersen graph</li><li><a href="prufer.html" class="code" title="function output = prufer(g, code)">prufer</a>	prufer --- convert a tree to/from its Prufer code</li><li><a href="random_planar.html" class="code" title="function random_planar(g,n)">random_planar</a>	random_planar(g,n) --- create a random planar triangulation</li><li><a href="random_tree.html" class="code" title="function random_tree(t,n)">random_tree</a>	random_tree(t,n) --- overwrite t with a random tree on n vertices</li><li><a href="selective.html" class="code" title="function selective(g,n,n0,d)">selective</a>	selective(g,n,n0,d) --- selective attachment random graph</li><li><a href="sgf.html" class="code" title="function A = sgf(g,M)">sgf</a>	sgf --- simple graph format: a 2-column matrix representation</li><li><a href="shiftgraph.html" class="code" title="function shiftgraph(g,k,t)">shiftgraph</a>	shiftgraph(g,k,t) -- create a shiftgraph g based on t-tuples of k symbols</li><li><a href="sl2graph.html" class="code" title="function sl2graph(g,p)">sl2graph</a>	sl2graph(g,p) -- create an SL(2,p) graph</li><li><a href="union.html" class="code" title="function union(g,h1,h2)">union</a>	union(g,h1,h2) --- set g equal to the union of h1 and h2.</li><li><a href="wheel.html" class="code" title="function wheel(g,n)">wheel</a>	wheel(g,n) --- overwrite g with a wheel graph on n vertices</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function resize(g, n)</a>
0002 <span class="comment">% resize(g,n) --- change the number of vertices in g to n</span>
0003 <span class="comment">% note: if n is less than nv(g), vertices will be lost</span>
0004 <span class="comment">% if the graph has an embedding, all new vertices are sited at the origin.</span>
0005 
0006 
0007 old_n = <a href="nv.html" class="code" title="function n = nv(g)">nv</a>(g);
0008 
0009 <span class="keyword">if</span> (n == old_n)   <span class="comment">% no change</span>
0010     <span class="keyword">return</span>
0011 <span class="keyword">end</span>
0012 
0013 <span class="keyword">global</span> GRAPH_MAGIC
0014 
0015 <span class="keyword">if</span> (n &lt; old_n)    <span class="comment">% shrink</span>
0016     GRAPH_MAGIC.graphs{g.idx}.array = <span class="keyword">...</span>
0017         GRAPH_MAGIC.graphs{g.idx}.array(1:n,1:n);
0018     <a href="make_logical.html" class="code" title="function make_logical(g)">make_logical</a>(g);
0019     <span class="keyword">if</span> <a href="hasxy.html" class="code" title="function yn = hasxy(g)">hasxy</a>(g)
0020         GRAPH_MAGIC.graphs{g.idx}.xy = <span class="keyword">...</span>
0021             GRAPH_MAGIC.graphs{g.idx}.xy(1:n,:);
0022     <span class="keyword">end</span>
0023     <span class="keyword">if</span> <a href="is_labeled.html" class="code" title="function yn = is_labeled(g)">is_labeled</a>(g)
0024         GRAPH_MAGIC.graphs{g.idx}.labels = <span class="keyword">...</span>
0025             GRAPH_MAGIC.graphs{g.idx}.labels(1:n);
0026     <span class="keyword">end</span>
0027     <span class="keyword">return</span>
0028 <span class="keyword">end</span>
0029 
0030 <span class="comment">% we need to add extra zeros to g's adjacency matrix. we decide what to do</span>
0031 <span class="comment">% based on g's storage class.</span>
0032 
0033 <span class="keyword">if</span> (<a href="isfull.html" class="code" title="function yn = isfull(g)">isfull</a>(g))
0034     A = zeros(old_n, n-old_n);
0035     B = zeros(n-old_n, n-old_n);
0036 <span class="keyword">else</span>
0037     A = <a href="sparse.html" class="code" title="function sparse(g)">sparse</a>([],[],[],old_n,n-old_n);
0038     B = <a href="sparse.html" class="code" title="function sparse(g)">sparse</a>([],[],[],n-old_n,n-old_n);
0039 <span class="keyword">end</span>
0040 
0041 <span class="keyword">if</span> <a href="hasxy.html" class="code" title="function yn = hasxy(g)">hasxy</a>(g)
0042     morexy = zeros(n-old_n,2);
0043     GRAPH_MAGIC.graphs{g.idx}.xy = <span class="keyword">...</span>
0044         [GRAPH_MAGIC.graphs{g.idx}.xy; morexy];
0045 <span class="keyword">end</span>
0046  
0047 <span class="keyword">if</span> <a href="is_labeled.html" class="code" title="function yn = is_labeled(g)">is_labeled</a>(g)
0048     newlabels = cell(n,1);
0049     <span class="keyword">for</span> k=1:old_n
0050         newlabels{k} = GRAPH_MAGIC.graphs{g.idx}.labels{k};
0051     <span class="keyword">end</span>
0052     <span class="keyword">for</span> k=(old_n+1):n
0053         newlabels{k} = int2str(k);
0054     <span class="keyword">end</span>
0055     GRAPH_MAGIC.graphs{g.idx}.labels = newlabels;
0056 <span class="keyword">end</span>
0057 
0058 GRAPH_MAGIC.graphs{g.idx}.array = <span class="keyword">...</span><span class="comment">    </span>
0059     [GRAPH_MAGIC.graphs{g.idx}.array, A; A', B];
0060 <a href="make_logical.html" class="code" title="function make_logical(g)">make_logical</a>(g);</pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>